package cn.ryh.listener.code.config;

import cn.ryh.listener.code.CodeServletContextListener;
import cn.ryh.listener.code.CodeSessionListener;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Rao
 * @Description
 * @create 2022-04-15 17:12
 */
@Configuration
public class CodeConfig {
    /**
     * 注册ServletContextListener
     *
     * @return
     */
    @Bean
    public ServletListenerRegistrationBean codeServletContextListener() {

        //自定义个Listener.监听ServletContext
        return new ServletListenerRegistrationBean<>(new CodeServletContextListener());
    }

    /**
     * 注册SessionListener
     *
     * @return
     */
    @Bean
    public ServletListenerRegistrationBean codeSessionListener() {

        return new ServletListenerRegistrationBean<>(new CodeSessionListener());
    }
}
